{extend name="public/layer_base"}

{block name="style"}
{js href="__PUBLIC__static/admin/icheck/icheck.css"}
{/block}

{block name="main"}
<form action="?" method="post" class="save_jurisdiction">

    <table class="table table-border table-bordered table-bg">
        <thead>
        <tr class="text-l">
            <th colspan="7" scope="col">
                <div class="check-box" style="padding-left: 0">
                    <input type="checkbox" id="checkbox" class="all select_all">
                    <label for="checkbox">全选</label>
                </div>
                权限分类</th>
        </tr>
        <tr class="text-c">
            <th width="100">导航名称</th>
            <th>权限列表</th>
        </tr>
        </thead>
        <tbody>
        {volist name="menu" id="vo" key="k"}
        <tr>
            <td>{$vo.name}</td>
            <td class="text-l">
                {volist name="vo.children" id="v"}
                <div class="check-box">
                    <input type="checkbox" id="checkbox-{$k}-{$i}" {php}if(in_array($key, $jurisdiction)) { echo 'checked';}{/php} name="jurisdiction[]" value="{$key}">
                    <label for="checkbox-{$k}-{$i}">{$v.name}</label>
                </div>
                {/volist}
            </td>
        </tr>
        </tbody>
        {/volist}
    </table>
    <div class="row cl mt-20">
        <div class="col-xs-8 col-sm-9">
            <button class="btn btn-primary radius" type="submit"><i class="Hui-iconfont">&#xe632;</i> 提 交 </button>
            <button onClick="layer_close();" class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
        </div>
    </div>
    <input type="hidden" name="id" value="{$id}">
</form>

{/block}

{block name="javascript"}
{js href="__PUBLIC__static/admin/icheck/jquery.icheck.min.js"}
<script>
    $(function(){
        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });

        $(".all").click(function () {
            var _this = $(this);
            var _id = _this.attr('id');
            if (_this.hasClass('select_all')) {
                $('input[type="checkbox"]').prop('checked',_this.prop("checked"));
//                $('input[type="checkbox"]').each(function (i, d) {
//                    if (_this.prop("checked")) {
//                        $(this).attr('checked', _this.prop('checked')).parent().addClass('checked');
//                    } else {
//                        $(this).attr('checked', _this.prop('checked')).parent().removeClass('checked');
//                    }
//                });
            } else {
                $("div[data-check='"+ _id +"']").find('input[type="checkbox"]').each(function (i, d) {
                    if (_this.prop("checked")) {
                        $(this).attr('checked', _this.prop('checked')).parent().addClass('checked');
                    } else {
                        $(this).attr('checked', _this.prop('checked')).parent().removeClass('checked');
                    }
                });
            }
        });
    });
</script>
{/block}